var vm=new Vue({
    el:"#question",
    data:{
        list: [],
        pageConf:{
            currentPage: 1, //当前页
            totalItems: 20,//总记录数
            itemsPerPage: 5,//每页记录数
            pageinationPage: 0,//可分页数
            pageinationLength: []
        }
    },
    created(){
        //初始化加载调用
        this.selectPage(1);
    },
    methods: {
        /*显示所有*/
        selectAll:function (){
            let that=this;
            axios.get("/question/selectAll.do").then(function (response){
               that.list=response.data;
               console.log(that.list);
            }).catch(function (error) {
                console.log(error);
            });
        },
        /*分页显示*/
        selectPage:function (page){

            let that=this;
            axios.get("/question/selectPage.do?page="+page+"&rows="+this.pageConf.itemsPerPage).then(function (response){
                that.list=response.data.rows;
                that.pageConf.totalItems=response.data.total;//定义总记录数
                console.log(response.data);
            }).catch(function (error) {
                console.log(error);
            });
            this.pages();
        },
        /*可分页数初始化*/
        pages:function (){
            //重置
            this.pageConf.pageinationLength = [];
            this.pageConf.pageinationPage=Math.ceil(this.pageConf.totalItems/this.pageConf.itemsPerPage);
            for (let i=1;i<=this.pageConf.pageinationPage;i++){
                this.pageConf.pageinationLength.push(i);
            }
        },
        //重新加载记录数
        reloadList:function (){
            this.selectPage(this.paginationConf.currentPage,this.paginationConf.itemsPerPage);
        }
    }

})